Skip to content

Suppress log spams in gcsio 3.0#38588

Merged
Abacn merged 2 commits into
apache:masterfrom
Abacn:disable-log-spam
May 22, 2026
Merged

Suppress log spams in gcsio 3.0#38588
Abacn merged 2 commits into
apache:masterfrom
Abacn:disable-log-spam

Conversation

@Abacn
Copy link
Copy Markdown
Contributor

@Abacn Abacn commented May 21, 2026

Please add a meaningful description for your change here

There is a "ALERT: Overriding httpRequestInitializer - this should not be done in production!" log added in gcsio 3.0. However, Beam does use a custom HttpInitializer handling retry/user-agent/ignore 404 warnings etc


Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:

  • Mention the appropriate issue in your description (for example: addresses #123), if applicable. This will automatically add a link to the pull request in the issue. If you would like the issue to automatically close on merging the pull request, comment fixes #<ISSUE NUMBER> instead.
  • Update CHANGES.md with noteworthy changes.
  • If this contribution is large, please file an Apache Individual Contributor License Agreement.

See the Contributor Guide for more tips on how to make review process smoother.

To check the build health, please visit https://github.com/apache/beam/blob/master/.test-infra/BUILD_STATUS.md

GitHub Actions Tests Status (on master branch)

Build python source distribution and wheels
Python tests
Java tests
Go tests

See CI.md for more information about GitHub Actions CI or the workflows README to see a list of phrases to trigger workflows.

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses excessive logging output that appeared after upgrading to gcsio 3.0. By programmatically adjusting the logging level for the specific class responsible for the alert, the change prevents log spam while maintaining necessary diagnostic information for severe issues.

Highlights

  • Log Suppression: Added logic to suppress unnecessary 'Overriding httpRequestInitializer' log warnings introduced in gcsio 3.0.
  • Implementation Details: Utilized an AtomicBoolean to ensure the logger level adjustment for 'com.google.cloud.hadoop.gcsio.GoogleCloudStorageImpl' is performed only once.
New Features

🧠 You can now enable Memory (public preview) to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a mechanism to suppress log spam from the GCS IO library by setting the log level of GoogleCloudStorageImpl to SEVERE during the first invocation of createGoogleCloudStorage. Feedback suggests renaming the AtomicBoolean for better clarity, using a class reference instead of a hardcoded string for the logger name to improve maintainability, and reconsidering the SEVERE log level to avoid suppressing potentially important diagnostic warnings.

return RetryDeterminer.SOCKET_ERRORS.shouldRetry(e);
}
};
private static final AtomicBoolean overwriteLog = new AtomicBoolean(false);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The variable name overwriteLog is somewhat ambiguous and could be interpreted as overwriting a log file. Renaming it to something like gcsioLoggerConfigured would more clearly indicate that it tracks whether the logging configuration for the GCS IO library has been applied.

Suggested change
private static final AtomicBoolean overwriteLog = new AtomicBoolean(false);
private static final AtomicBoolean gcsioLoggerConfigured = new AtomicBoolean(false);

Comment on lines +735 to +740
if (overwriteLog.compareAndSet(false, true)) {
java.util.logging.Logger gcsLogger =
java.util.logging.Logger.getLogger(
"com.google.cloud.hadoop.gcsio.GoogleCloudStorageImpl");
gcsLogger.setLevel(java.util.logging.Level.SEVERE);
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Using GoogleCloudStorageImpl.class.getName() is preferred over a hardcoded string to ensure type safety and ease of refactoring. Additionally, please note that setting the log level to SEVERE is very aggressive as it suppresses all WARNING and INFO messages from this class, which might contain important diagnostic information. If the intention is only to suppress the specific "ALERT" message, consider if WARNING is sufficient or if this suppression should be made configurable.

    if (gcsioLoggerConfigured.compareAndSet(false, true)) {
      java.util.logging.Logger gcsLogger =
          java.util.logging.Logger.getLogger(GoogleCloudStorageImpl.class.getName());
      gcsLogger.setLevel(java.util.logging.Level.SEVERE);
    }

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The spamming log is a WARN log, see PR description

GoogleCloudStorage createGoogleCloudStorage(
GoogleCloudStorageOptions options, Storage storage, Credentials credentials)
throws IOException {
// Suppress log spams in gcsio 3.0
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested working with ./gradlew :sdks:java:testing:jpms-tests:dataflowRunnerIntegrationTest -info. If put it in a static block it's not effective because the root logger hasn't been initialized yet

@Abacn
Copy link
Copy Markdown
Contributor Author

Abacn commented May 21, 2026

R: @Amar3tto

@Abacn
Copy link
Copy Markdown
Contributor Author

Abacn commented May 21, 2026

R: @shunping

@github-actions
Copy link
Copy Markdown
Contributor

Stopping reviewer notifications for this pull request: review requested by someone other than the bot, ceding control. If you'd like to restart, comment assign set of reviewers

1 similar comment
@github-actions
Copy link
Copy Markdown
Contributor

Stopping reviewer notifications for this pull request: review requested by someone other than the bot, ceding control. If you'd like to restart, comment assign set of reviewers

@Abacn Abacn added this to the 2.74.0 Release milestone May 21, 2026
static reference exist in GoogleCloudStorageImpl
@Abacn Abacn merged commit 9d307e5 into apache:master May 22, 2026
18 checks passed
Abacn added a commit that referenced this pull request May 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants